﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Abp.Domain.Repositories;
using KelonProud.Administration.Domain.Configuration;
using KelonProud.Linq;
using Microsoft.EntityFrameworkCore;

namespace KelonProud.Administration.Managers.Configuration
{
    public class IconManager: KelonProudDomainService<KelonProudIcon>
    {
        public IconManager(IRepository<KelonProudIcon, int> manageRepository) : base(manageRepository)
        {
        }

        public List<KelonProudIcon> GetIcons()
        {
            return List;
        }

        public List<KelonProudIcon> GetIconsByName(string name)
        {
            return Query.Where(w => w.Name.Contains(name)).ToList();
        }

        public Task<List<KelonProudIcon>> GetIconsByNameAsync(string name)
        {
            return name.HasValue()? Query.Where(w => w.Name.Contains(name)||w.Keywords.Contains(name)).ToListAsync():ListAsync;
        }
    }
}
